package com.ibm.ems.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


import com.ibm.ems.dto.PromotionBean;

public class PromotionDAO {
	
	private Connection conn;

	public PromotionDAO(Connection conn) {
		this.conn = conn;
	}
		public void CreatePromotion(PromotionBean p) throws SQLException{
			PreparedStatement pstmt = null;
			
			ResultSet rs = null;
			try {
				
				
				pstmt = conn.prepareStatement("Insert into promotion values (?,?,?,?,?)");
				pstmt.setString(1,p.getProId());
				pstmt.setString(2, p.getProCode());
				pstmt.setDate(3,new java.sql.Date(p.getSDate().getTime()));
				pstmt.setDate(4,new java.sql.Date(p.getEDate().getTime()));
				pstmt.setString(5,p.getDisPercentage());
							
			  rs = pstmt.executeQuery();
			
			
			} catch (SQLException ex) {
				System.out.print("Exception");
			} finally {
				try {
					if (rs != null)
						rs.close();
					if (pstmt != null)
						pstmt.close();
				} catch (Exception ex1){
					
				}
			
		 }
			conn.close();
		}
}
	
	
	
	


